using Microsoft.EntityFrameworkCore;
using Mall.Api.Entity;

namespace Mall.Api.Db
{
    public class AdminDb : DbContext
    {
        // 因为我们使用AddDbContext到容器，所以此处必须得有带参数的构造函数（而且必须传递DbContextOptions类型的参数，同时父类也得调用这个参数）
        public AdminDb(DbContextOptions options) : base(options)
        {

        }

        public DbSet<Users> Users { get; set; }
        public DbSet<Roles> Roles { get; set; }
        public DbSet<Comments> Comments { get; set; }
        public DbSet<CommentsClass> CommentsClasses { get; set; }
        public DbSet<Commodity> Commodity { get; set; }
        public DbSet<CommodityProperty> CommodityProperty { get; set; }
        public DbSet<CommodityPropertyValue> CommodityPropertyValue { get; set; }
        public DbSet<CommodityResources> CommodityResources { get; set; }
        public DbSet<CommoditySKU> CommoditySKU { get; set; }
        public DbSet<CommodityWarehouse> CommodityWarehouse { get; set; }
        public DbSet<Brand> Brand { get; set; }
        public DbSet<Class> Class { get; set; }
        public DbSet<Order> Order { get; set; }
        public DbSet<OrderStatu> OrderStatu { get; set; }
        public DbSet<Payment> Payment { get; set; }
        public DbSet<Resource> Resource { get; set; }
        public DbSet<ShoppingCart> ShoppingCart { get; set; }
        public DbSet<Warehouse> Warehouse { get; set; }
        public DbSet<WebsiteInfo> WebsiteInfo { get; set; }
        public DbSet<WebsiteOtherInfo> WebsiteOtherInfo { get; set; }
        public DbSet<Jurisdiction> Jurisdiction { get; set; }
        public DbSet<RolesJurisdiction> RolesJurisdiction { get; set; }
        public DbSet<Supplier> Supplier { get; set; }
        public DbSet<UserOrder> UserOrder { get; set; }
        public DbSet<UserShoppingTrolley> UserShoppingTrolley { get; set; }
        public DbSet<AuditInfo> AuditInfo { get; set; }



        protected override void OnConfiguring(DbContextOptionsBuilder builder)
          => builder.UseSqlServer(@"server=LAPTOP-NT2O3C2R\SQLEXPRESS;database=Mall;uid=xiaoyou;pwd=5a2699yu;");



        protected override void OnModelCreating(ModelBuilder model)
        {

            model.Entity<Jurisdiction>().HasData(
                  new Jurisdiction
                  {
                      Id = 1,
                      JurisdictionName = "无"
                  },
                  new Jurisdiction
                  {
                      Id = 2,
                      JurisdictionName = "所有权限"
                  },
                  new Jurisdiction
                  {
                      Id = 3,
                      JurisdictionName = "基本权限"
                  },
                  new Jurisdiction
                  {
                      Id = 4,
                      JurisdictionName = "用户权限"
                  },

                  new Jurisdiction
                  {
                      Id = 6,
                      JurisdictionName = "角色权限"
                  },
                  new Jurisdiction
                  {
                      Id = 7,
                      JurisdictionName = "图片权限"
                  }

              );





            model.Entity<Roles>().HasData(
                   new Roles
                   {
                       Id = 1,
                       RoleName = "普通用户"
                   },
                   new Roles
                   {
                       Id = 2,
                       RoleName = "管理员"
                   },
                   new Roles
                   {
                       Id = 3,
                       RoleName = "超级管理员"
                   },
                   new Roles
                   {
                       Id = 4,
                       RoleName = "供应商"
                   }

               );





            model.Entity<RolesJurisdiction>().HasData(
                 new RolesJurisdiction
                 {
                     Id = 1,
                     RolesId = 1,
                     JurisdictionId = 1


                 },
                 new RolesJurisdiction
                 {
                     Id = 2,
                     RolesId = 2,
                     JurisdictionId = 3
                 },
                 new RolesJurisdiction
                 {
                     Id = 3,
                     RolesId = 3,
                     JurisdictionId = 2
                 }

             );






            model.Entity<Users>().HasData(
                new Users
                {
                    Id = 1,
                    Nickname = "小可爱",
                    Username = "xiaoyou",
                    Password = "123456",
                    RolesId = 3,
                    Balance = 10000,
                    Txcolor = "white",
                    Bgcolor = "blue"


                },
                new Users
                {
                    Id = 2,
                    Nickname = "嘿",
                    Username = "xiaoai",
                    Password = "123456",
                    RolesId = 1,
                    Balance = 1000,
                    Txcolor = "white",
                    Bgcolor = "blue"

                }


            );





            model.Entity<WebsiteInfo>().HasData(
                new WebsiteInfo
                {
                    Id = 1,
                    Owner = "xiaoai",
                    Introduce = "就爱科技有限公司",
                    Phone = "15270759789",
                    Address = "福建省龙岩市新罗区",
                    Mailbox = "1254412212@qq.com",
                    Url = "www.9ihub.com",
                    WebsiteICP = "京ICP备12020869号-2",
                    PutOnRecords = "京公网安备44010602000207",

                }

            );





            model.Entity<Resource>().HasData(
               new Resource
               {
                   Id = 1,
                   ResourceName = "default.jpg"

               },
               new Resource
               {
                   Id = 2,
                   ResourceName = "default.jpg"
               }

           );


            model.Entity<Brand>().HasData(
                new Brand
                {
                    Id = 1,
                    BrandName = "华为"

                },
                new Brand
                {
                    Id = 2,
                    BrandName = "小米"
                },
                new Brand
                {
                    Id = 3,
                    BrandName = "鸿星尔克"
                }

            );



            model.Entity<Class>().HasData(
                new Class
                {
                    Id = 1,
                    ClassName = "手机",
                    ClassPriority = 1

                },
                new Class
                {
                    Id = 2,
                    ClassName = "电脑",
                    ClassPriority = 2
                },
                new Class
                {
                    Id = 3,
                    ClassName = "鞋子",
                    ClassPriority = 3

                }

            );




            model.Entity<CommodityProperty>().HasData(
               new CommodityProperty
               {
                   Id = 1,
                   PropertyName = "颜色"

               },
               new CommodityProperty
               {
                   Id = 2,
                   PropertyName = "尺码"
               },
               new CommodityProperty
               {
                   Id = 3,
                   PropertyName = "版本"

               },
              new CommodityProperty
              {
                  Id =4,
                  PropertyName="款式"
              },
              new CommodityProperty
              {
                  Id =5,
                  PropertyName="类别"
              },
              new CommodityProperty
              {
                  Id =6,
                  PropertyName="口味"
              },
              new CommodityProperty
              {
                  Id =7,
                  PropertyName="种类"
              },
              new CommodityProperty
              {
                  Id =8,
                  PropertyName="规格"
              }

           );



            // model.Entity<CommodityPropertyValue>().HasData(
            //     new CommodityPropertyValue
            //     {
            //         Id = 1,
            //         CommodityPropertyId = 1,
            //         PropertyValue = "16G"
            //     },
            //     new CommodityPropertyValue
            //     {
            //         Id = 2,
            //         CommodityPropertyId = 1,
            //         PropertyValue = "32G"
            //     },
            //     new CommodityPropertyValue
            //     {
            //         Id = 3,
            //         CommodityPropertyId = 1,
            //         PropertyValue = "64G"
            //     }

            // );




            model.Entity<Commodity>().HasData(
               new Commodity
               {
                   Id = 1,
                   ProductCode = "1233444",
                   ProductName = "啊反垄断法",
                   Introduction = "爱得发疯",
                   ClassId = 1,
                   SupplierId = 1,
                   Price = 1000,
                   OriginalPrice = 1000

               }

           );




            model.Entity<Supplier>().HasData(
                new Supplier
                {
                    Id = 1,
                    AccountName = "1233444",
                    AccountPassword = "123456",
                    SupplierName = "爱得发疯",
                    Owner = "xiaoai",
                    ManagementTypes = "fdaffd",
                    BrandId = 1,
                    Introduction = "阿凡达发发的发的",
                    Address = "福建龙岩",
                    Phone = "15270759789",
                    Quantity = 100,
                    StoreName = "爱得发疯商店",
                    Priority = 1,
                    RolesId = 4


                }

            );






            model.Entity<CommodityWarehouse>().HasData(
                new CommodityWarehouse
                {
                    Id = 1,
                    CommodityId = 1,
                    WarehouseId = 1,
                    AddNumber = 1

                }

            );



            model.Entity<Warehouse>().HasData(
                new Warehouse
                {
                    Id = 1,
                    WarehouseName = "就爱仓库",
                    Province = "福建",
                    City = "龙岩",
                    QuantityInStock = 100,
                    UnsuppliedAddress = "上海"

                }

            );

            model.Entity<Payment>().HasData(
               new Payment
               {
                   Id = 1,
                   PaymentName = "支付宝"

               },
               new Payment
               {
                   Id = 2,
                   PaymentName = "微信"

               },
                new Payment
                {
                    Id = 3,
                    PaymentName = "银行卡"

                }

           );




            model.Entity<OrderStatu>().HasData(
                new OrderStatu
                {
                    Id = 1,
                    StatuName = "已付款"

                },
                new OrderStatu
                {
                    Id = 2,
                    StatuName = "未付款"

                }

            );



        }






    }

}


